#ifndef MEMORYPOLL_H
#define MEMORYPOLL_H

#include"MutexLock.h"
#include<string.h>
#include<vector>
#include <memory>

const int MemorySize[] = {512, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 4608, 5120};
const int BasicUnit = 512;

struct MemoryList
{
    MemoryList* nexthead;
};

class memorypool
{
public:
    typedef std::vector<std::shared_ptr<MemoryList>> MemoryIndex;

    memorypool();

    ~memorypool();

    void push(void* recycle, size_t size);

    void* task(size_t size);


private:
    void pushte(void* recycle, size_t size);

    char* refill(size_t size, int &num);

    MemoryIndex MemoryIndex_;
    MutexLock locker_;
    char* start_pool;
    char* end_pool;
    

}; // class memorypool end


#endif